package com.designPattern.bridge.connection;

import com.designPattern.bridge.connection.driver.DriverManager;
import com.designPattern.bridge.connection.driver.MysqlDriver;
import com.designPattern.bridge.connection.driver.OracleDriver;

/**
 * show how to get Connection from Database
 * 1.choose the Driver -->  Driver driver = class.forName("the Driver class")
 * 2.you need to register the Driver firstly --> DriverManager.register(driver)
 * 3.get Connection  --> DriverManager.getConnection()
 * @author mxs
 */
public class QuickUse {
    public static void main(String[] args) {
        //DriverManager注册驱动，注册驱动的真实含义是获取驱动
        DriverManager.register(new MysqlDriver());
        //获取数据库连接
        Connection connection = DriverManager.getConnection();
        //获取数据库连接的信息
        connection.connectionInfo();


        DriverManager.register(new OracleDriver());
        Connection connection1 = DriverManager.getConnection();
        connection1.connectionInfo();
    }
}
